import { defineStore } from 'pinia';

interface ObjectList {
    [key: string]: string[];
}

export const usePermissStore = defineStore('permiss', {
    state: () => {
        const keys = localStorage.getItem('ms_keys');
        return {
            key: keys ? JSON.parse(keys) : <string[]>[],
            defaultList: <ObjectList>{
                admin: [
                    '0',
                    '1',
                    '11',
                    '12',
                    '13',
                    '2',
                    '21',
                    '22',
                    '23',
                    '24',
                    '25',
                    '26',
                    '27',
                    '28',
                    '29',
                    '291',
                    '292',
                    '3',
                    '31',
                    '32',
                    '33',
                    '34',
                    '4',
                    '41',
                    '42',
                    '5',
                    '7',
                    '6',
                    '61',
                    '62',
                    '63',
                    '64',
                    '65',
                    '66',
                ],
                user: ['0', '1', '11', '12', '13'],
            },
        };
    },
    actions: {
        handleSet(val: string[]) {
            this.key = val;
        },
    },
});
